/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package staffTests;

import java.util.Calendar;
import model.Constants;
import model.personInfo.Contacts;
import model.personInfo.Name;
import model.personInfo.Origin;
import model.staff.Degree;
import model.staff.Teacher;
import org.junit.After;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;

/**
 *
 * @author Dmitri Paziy
 */
public class TeacherTest {
    private Teacher teacher;
    
    private final Name name;
    private final Origin origin;
    private final Contacts contacts;
    
    public TeacherTest() {
        name = new Name("Juriy", "Bohonov");
        origin = new Origin(Calendar.getInstance().getTime(), "Kyiv");
        contacts = new Contacts("12345", "Kyiv");
    }
    
    @Before
    public void setUp() {
        teacher = new Teacher(name, origin, contacts);
    }
    
    @After
    public void tearDown() {
    }
    
    @Test
    public void shouldReturnDefaultSalaryWhenSalaryNotSet() {
        //given
        int expected = Constants.MINIMAL_SALARY;
        //then
        assertEquals(expected, teacher.getSalary());
    }
    
    @Test(expected=IllegalArgumentException.class)
    public void shouldThrowIllegalArgumentExceptionWhenSetNegativeSalary() {
        teacher.setSalary(-1);
    }
    
    @Test
    public void shouldChangeSalaryWhenSet() {
        //given
        int expected = Constants.MINIMAL_SALARY + 5;
        //when
        teacher.setSalary(expected);
        //then
        assertEquals(expected, teacher.getSalary());
    }
    
    @Test
    public void shouldChangeSalaryWhenChangeSalary() {
        //given
        int expected = teacher.getSalary() + 100;
        //when
        teacher.changeSalary(100);
        //then
        assertEquals(expected, teacher.getSalary());
    }
    
    @Test
    public void shouldReturnDefaultDegreeWhenDegreeNotSet() {
        //given
        Degree expected = Degree.Doctor;
        //then
        assertEquals(expected, teacher.getDegree());
    }
    
    @Test(expected=IllegalArgumentException.class)
    public void shouldThrowIllegalArgumentExceptionWhenSetNullDegree() {
        teacher.setDegree(null);
    }
    
    @Test
    public void shouldChangeDegreeWhenSet() {
        //given
        Degree expected = Degree.Professor;
        //when
        teacher.setDegree(expected);
        //then
        assertEquals(expected, teacher.getDegree());
    }
}
